<?php
class emailhash {
	private $email;
	private $crc32_value;
	private $md5_value;
	
	function __construct($email){
		$this->email = $email;
		$this->normalize();
	}
	
	public function getHash($email = false){
		if($email){
			$this->email = $email;
			$this->normalize();
		}
		
		$this->crc32_value();
		$this->md5_value();
		return "{$this->crc32_value}_{$this->md5_value}";
	}
	
	private function normalize(){
		$this->email = mb_strtolower(trim($this->email), 'utf-8');
	}
	
	private function crc32_value(){
		$this->crc32_value = crc32($this->email);
		$this->crc32_value = sprintf("%u", $this->crc32_value);
	}
	
	private function md5_value(){
		$this->md5_value = md5($this->email, false);
	}
}

?>